﻿using LiSAClient.Core.Models;

namespace LiSAClient.WpfClient.View.Frame
{
    using System.Windows;
    using System.Windows.Controls;
    using LiSAClient.Core.Messages;
    using GalaSoft.MvvmLight.Messaging;

    /// <summary>
    ///     Interaction logic for UserInfo.xaml
    /// </summary>
    public partial class UserInfo
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="UserInfo"/> class.
        /// </summary>
        /// <param name="loggedInUser">
        /// The logged In User.
        /// </param>
        public UserInfo(/*User loggedInUser*/)
        {
            /*this.CurrentUser = loggedInUser;*/
            this.InitializeComponent();
        }


        private void UserActionsButton_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            if (button != null)
            {
                button.ContextMenu.IsEnabled = true;
                button.ContextMenu.PlacementTarget = button;
                button.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Left;
                button.ContextMenu.IsOpen = true;
                button.ContextMenu.VerticalOffset = button.ActualHeight;
                button.ContextMenu.HorizontalOffset = button.ActualWidth;
            }
        }
        #endregion

        private void Logout_OnClick(object sender, RoutedEventArgs e)
        {
            Messenger.Default.Send(new LogoutMessage());
            var window = Window.GetWindow(this);
            if (window != null)
            {
                window.Close();
            }
        }

        private void Setup_OnClick(object sender, RoutedEventArgs e)
        {
            Messenger.Default.Send(new ShowNotificationMessage
            {
                Header = "Settings",
                Body = "This is where you will be able to edit your user settings.",
                NotificationType = NotificationType.Info
            });
        }

        private void Profile_OnClick(object sender, RoutedEventArgs e)
        {
            Messenger.Default.Send(new ShowNotificationMessage
            {
                Header = "Profile",
                Body = "This is where you will be able to edit your user profile",
                NotificationType = NotificationType.Info
            });
        }
    }
}
